package com.modificial.springboot.listener;

import com.modificial.springboot.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author modificial
 */
@Component
public class StartListener implements ApplicationListener<ApplicationReadyEvent> {


    @Autowired
    private ScheduleService scheduleService;

    /**
     * 加入spring监听事件
     *
     * @param event
     */

    @Override
    public void onApplicationEvent(final ApplicationReadyEvent event) {
        try {
            scheduleService.testScheduleTask();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}